package com.sg.business.commons.field.validator;

import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.forms.IMessageManager;

import com.mobnut.db.model.PrimaryObject;
import com.sg.business.model.User;
import com.sg.widgets.commons.valuevalidator.IFieldInputValidator;
import com.sg.widgets.registry.config.FieldConfigurator;

public class UserNameFormat implements IFieldInputValidator {

	@Override
	public boolean validate(PrimaryObject data,
			FieldConfigurator fieldConfigurator, Object valueForUpdate,
			IMessageManager messageManager, Control control) {
		if(valueForUpdate != null) {
			String valueString = (String)valueForUpdate;
			valueString = valueString.trim();
			data.setValue(User.F_USER_NAME,valueString);
		}
		return true;
	}

}
